package com.runvp.init;

import com.runvp.netty.server.NettyBufServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * spring boot 容器加载后自动监听
 */
@Slf4j
@Component
public class MyCommandRunner implements CommandLineRunner {

    @Autowired
    private NettyBufServer nettyBufServer;

    @Override
    public void run(String... args) {
        try {
            //开启Netty服务
            nettyBufServer.bind();
            log.info("======服务已经启动========");
        } catch (Exception e) {
            log.error("服务启动失败：{}",e);
        }
    }
}